package com.project.demo.entity;

import com.project.demo.enums.ResultCode;
import lombok.Data;

import java.io.Serializable;

@Data
public class Result<T> implements Serializable {

	private static final long serialVersionUID = 1L;

	//响应码
	private Integer code;

	//响应信息
	private String msg;

	//返回数据
	private T data;

	public Result() {
	}

	public Result(int code, String msg, T data) {
		this.code = code;
		this.msg = msg;
		this.data = data;
	}

	public Result(int code, String msg) {
		this.code = code;
		this.msg = msg;
		this.data = (T) "";
	}

	public Result(ResultCode resultCode) {
		super();
		this.code = resultCode.getCode();
		this.msg = resultCode.getDesc();
		this.data = (T) "";
	}

	public Result(T data) {
		this.data = data;
		this.code = 200;
		this.msg = "success";
	}

	public Result(ResultCode resultCode, T data) {
		super();
		this.code = resultCode.getCode();
		this.msg = resultCode.getDesc();
		this.data = data;
	}

}
